
window.onload =function () {

    //音乐
    // document.getElementById('miuc').onclick = function() {
    //     let mic = document.getElementById('mic')
    //     if(mic.paused) {
    //         document.getElementById('mic').play();
    //         document.getElementById('miuc').scr = './imgs/stop.png'
    //     }else {
    //         document.getElementById('mic').pause()
    //     }
        
    // }


    document.getElementById('onlod').onclick =function() {
        document.getElementById('sign').style.display = 'block';//登录显示
        document.querySelector('.sign').onclick = function () {

            let paly = document.querySelector('.pleayer').value;
            if(paly == '' || paly == null) {
                alert('玩家名称不能为空')
                return;
            }//判断玩家名称是否为空

            document.getElementById('playerID').textContent = document.querySelector('.pleayer').value;
            document.getElementById('sign').style.display = 'none';//登录隐藏
            document.getElementById('box').style.display= 'none';//主界面隐藏
            document.getElementById('box_blood').style.display= 'block'//玩家属性显示
            let mic = document.getElementById('mic')
            // if(mic.paused) {
            //     document.getElementById('mic').play();
            //     document.getElementById('miuc').scr = './imgs/stop.png'
            // }else {
            //     document.getElementById('mic').pause()
            // }

            //获取玩家id存得分数据
            function geamname() {
                let uname =  document.getElementById('playerID').textContent;
                let unumber = document.getElementById('fen').textContent;
                
                let parslocal =  JSON.parse(localStorage.getItem('geame')) ;//获取local储存数据
                console.log(parslocal)
                if(parslocal == '' || parslocal == null ) {//判断locar内是否存在内容 不存在
                    localStorage.setItem('geame',JSON.stringify([{
                        uname,
                        unumber:[
                            unumber
                        ]
                    }]))
                }else {
                    let flag = false;
                    parslocal.forEach(item => {
                        if(item.uname == uname) {
                            flag = true;
                            item.unumber.push(unumber);
                        }
                    })
                    if (!flag) {//不存在locar内 则添加
                        parslocal.push(
                            {
                                uname,
                                unumber:[
                                    unumber
                                ]
                            }
                        );
                       
                    }
                    localStorage.setItem('geame',JSON.stringify(parslocal));  
                }
            }
            //排行榜
            let big;
            document.querySelector('.see').onclick =RankingList;
            function RankingList() {
                document.getElementById('geameoverbox').style.display = 'none';
                document.getElementById('RankingList').style.display= 'block';
                let newlocar = JSON.parse(localStorage.getItem('geame')) ;;
                let n = 1;
                newlocar.forEach(item => {
                    console.log()
                    // let max_numvber = Math.max()
                    item.unumber.sort(function(a,b){
                        return b-a
                    })
                    
                    document.getElementById('RankingListbox').innerHTML +=`
                    <div class="player_fen">
                        <p class="serial_number"><span>${n}</span></p>
                        <p class="id"><span>${item.uname}</span></p>
                        <p class="maxfen"><span>${item.unumber[0]}</span></p>
                    </div>
                    `
                    n++
                })
               
            }
            //重新开始
            document.querySelector('.new').onclick =function () {
                window.location.replace("http://localhost:8080/index.html");
            }
           
            window_onload()
            let flag_left =false,
                    flag_top =false,
                    flag_right =false,
                    flag_down =false;

            //获取主要角色
            let lead = document.getElementById('lead');
            let move = 1;
            let arr =[];
            let arr_keyCode;
            let now = 0;
            Random_location();

            document.onkeydown = lead_move;

            document.onkeyup   = lead_shop_move;
            document.onkeypress = function(event) {
                let keyCode = event.keyCode;
                switch(keyCode){
                    case 65:
                        flag_left =true;
                        break;
                    case 87:
                        flag_top =true; 
                        break;
                    case 68:
                        flag_right = true; 
                        break;
                    case 83:
                        flag_down =  true;
                        break;
                    case 74:
                        document.getElementById('arms').style.display = 'none';
                        break;
                }
                foo();
            }
            //玩家位置等相关
            function lead_move(event) {

                let keyCode = event.keyCode,
                    left    = lead.offsetLeft,
                    top   = lead.offsetTop;
                arr.push(keyCode);
                arr_keyCode = arr.join();
                let arr_bulletfly = arr_keyCode.substr(arr_keyCode.lastIndexOf(',')+1);
                //最好一个方向的位置
                let arr_left =arr_keyCode.lastIndexOf('65');
                let arr_right = arr_keyCode.lastIndexOf('68');
                let arr_max = (arr_left > arr_right)? '65':'68';
                        
                
                if(keyCode == 65) {
                    flag_left =true;
                    document.querySelector('#lead_boy').src = './imgs/2_2.gif';
                    document.getElementById('arms').style.left = '5px';
                }
                if(keyCode == 87 ) {
                    flag_top =true; 
                }
                if(keyCode == 68) {
                    flag_right = true; 
                    document.querySelector('#lead_boy').src = './imgs/1_2.gif';
                    document.getElementById('arms').style.left = '25px';
                }
                if(keyCode == 83) {
                    flag_down =  true;
                }
                if(keyCode == 74) {
                    see_data(left,top,arr_max,arr_bulletfly)
                    
                    // Bulletfiring()
                }
                
                foo()
                // setTimeout(function(){
                    // if(flag_left){
                    //     lead.style.left = left -10 + 'px';             
                    // }
                    // if(flag_right){
                    //     lead.style.left = left + 10 + 'px';
                    // }
                    // if(flag_top){
                    //     lead.style.top = top -10+ 'px';
                    // }
                    // if(flag_down){
                    //     lead.style.top = top +10 + 'px';
                    // }
                // },1)
            }

            function see_data(left,top,arr_max,arr_bulletfly) {
                let data = document.getElementById('bullet').getAttribute('data-key');
                if(data == 'ordinary') {
                    if(now < 10) {
                        document.getElementById('arms').style.display = 'block';
                        Bulletfiring(left,top,arr_max,arr_bulletfly);
                        document.querySelector('.wen').textContent = document.querySelector('.wen').textContent -1;
                        now++
                    }
                    
                }
                if(data == 'Cold_ice') {
                    if(now < 5) {
                        document.getElementById('arms').style.display = 'block';
                        Lasergun(left,top,arr_max,arr_bulletfly)
                        document.querySelector('.wen').textContent = document.querySelector('.wen').textContent -1;
                        now++
                    }
                }
                if(data == 'Flame'){}
            }
            function foo() {
                let left    = lead.offsetLeft,
                    top   = lead.offsetTop;


                if(flag_left){
                    left = (left < 40)? 40: left-10
                    lead.style.left = left + 'px';             
                }
                if(flag_right){
                    left = (left > 1120)? 1120: left+10
                    lead.style.left = left + 'px';
                }
                if(flag_top){
                    top =  (top < 20)? 20: top - 10
                    lead.style.top = top+ 'px';
                }
                if(flag_down){
                    top =  (top > 520)? 520: top + 10
                    lead.style.top = top + 'px';
                }
            }
            // 清楚移动
            function lead_shop_move(event) {
                let keyCode = event.keyCode;
                switch(keyCode){
                    case 65:
                        flag_left =false;
                        break;
                    case 87:
                        flag_top =false; 
                        break;
                    case 68:
                        flag_right = false; 
                        break;
                    case 83:
                        flag_down =  false;
                        break;
                    case 74:
                        document.getElementById('arms').style.display = 'none';
                        break;
                }
                foo();
            }

            //角色随机位置
            function Random_location(){
                let arr = [
                    {
                        left: 150,
                        top:70
                    },
                    {
                        left: 1000,
                        top:450
                    },
                    {
                        left: 820,
                        top: 80
                    },
                    {
                        left: 250,
                        top:360
                    },
                    {
                        left: 920,
                        top: 70
                    }
                ];
                let random_number =  parseInt(Math.random()*4);
                lead.style.left = arr[random_number].left +'px';
                lead.style.top  = arr[random_number].top +'px'; 
            }
            

        
            // 怪物创建 ，怪物血量
            let boss_number =0;
            let boss_arr=[
                {
                    left: -10,
                    top:275
                },
                {
                    left: 1210,
                    top:275
                },
                {
                    left: 275,
                    top: 0
                },
                {
                    left: 925,
                    top: 600
                }
            ]
            function boos_move(num) {
                if(num < 5000) {
                    return;
                }
                let boss = document.querySelector('.first_boss');
                
                if(boss) {
                    return;
                }
                let random_position = parseInt(Math.random()*4);
                let p      = document.createElement('p');
                let boss_p = document.createElement('p');
                let imgs   = new Image();
                imgs.src   = './imgs/20.gif';
                boss_p.style.left = boss_arr[random_position].left +'px';
                boss_p.style.top = boss_arr[random_position].top +'px';
                boss_p.append(imgs);
                boss_p.className = 'boss_move';
                document.getElementById('biggestbox').append(boss_p); 
                
                // if(move > 20) {
                //     move = move + 5 ;
                // }else {
                    move = move + 1;
                // }
                $('.boss_move').attr("data-key",5+Number(move));
                n = 0;
               
            }
            //创建bosss
            function first_boss() {
                let first_boss_p = document.createElement('p');
                let imgs   = new Image();
                imgs.src   = './imgs/boss3.gif';
                first_boss_p.style.left =  0 +'px';
                first_boss_p.style.top = 75 +'px';
                first_boss_p.append(imgs);
                first_boss_p.className = 'first_boss';
                document.getElementById('biggestbox').append(first_boss_p); 
                $('.first_boss').attr("data-key",100);
            }
            // let newarms=[
            //     {
            //         left: 200,
            //         top:200
            //     },
            //     {
            //         left: 200,
            //         top:400
            //     },
            //     {
            //         left: 800,
            //         top: 200
            //     },
            //     {
            //         left: 1200,
            //         top:400
            //     }
            // ];
           
            
            //血包
            let arr_blood=[
                {
                    left: 400,
                    top:200
                },
                {
                    left: 400,
                    top:400
                },
                {
                    left: 800,
                    top: 200
                },
                {
                    left: 800,
                    top:400
                }
            ];
            function blood(mc) {
                if(mc < 20000) {
                    return;
                }
                
                let blood = document.querySelector('.blood');
               
                if(blood) {
                    m =0;
                    return;
                }
                let blood_random = parseInt(Math.random()*4);
                let p_blood = document.createElement('p');
                let imge = new Image();
                imge.src = './imgs/blood.png'
                p_blood.append(imge);
                p_blood.style.left = arr_blood[blood_random].left + 'px';
                p_blood.style.top = arr_blood[blood_random].top + 'px';
                p_blood.className = 'blood';
                document.getElementById('biggestbox').append(p_blood); 
                m = 0;
            }

            //随机位置生成地方角色，向某个方向移动 延时器
            function window_onload() {
                let lead = document.getElementById('lead');
                setTimeout(function(){
                    boos_move();
                    bulletfly();
                },2000)

            }

            //追踪
            let boss_blood=1;
            function track() {
                document.querySelectorAll('.boss_move').forEach(item => {
                    
                    let left    = lead.offsetLeft,
                        top   = lead.offsetTop;
                        boss_left = item.offsetLeft,
                        boss_top = item.offsetTop;
                        
                       
                    if(left !== boss_left || top !== boss_top) {

                        if(boss_left >= (left- 50) && boss_left <= (left + 50)){
                            if(boss_top >= top && boss_top <= top + 50) {
                                let lead_number = document.getElementsByClassName('lead_number')[0];//血条
                                lead_number.textContent = lead_number.textContent - 1;//碰到血条减1

                                item.remove();//减血清楚敌人
                                // let color = document.querySelectorAll('.color');
                                // console.log(color)
                                // color[document.querySelectorAll('.color').length-1].remove();
                                // boss_blood++;
                            
                                if(lead_number.textContent <= 0){//当血条为0时候
                                    lead.remove();
                                    document.getElementById('geameoverbox').style.display= 'block'
                                    geamname();
                                }
                            
                            }
                        }
                        if(boss_left < left){
                            item.style.left = boss_left + 1 +'px'
                        }else {
                            item.style.left = boss_left - 1 +'px'
                        }
                    
                        if(boss_top <  top){
                            item.style.top = boss_top + 1+'px'
                        }else {
                          
                            item.style.top = boss_top - 1 +'px'
                        } 
                    }
                });
                
            }
            
            //普通飞镖
            function Bulletfiring(left,top,n,x){
                let arms = document.getElementById('arms');
                if(arms.style.display !== 'block') {
                    return;
                }
                let imgs =new Image();

                imgs.src ='./imgs/12.png';//子弹图片
                let bullet =  document.createElement('p');
                bullet.className = '_arms';
                // $('#arms').attr("data-key",'ordinary');
                //子弹位置
                
                if(x ==74) {
                    if(n == 65 ) {
                        bullet.style.left = left+'px';
                        bullet.style.top = top+ 25 +'px';
                    }else if( n == 68) {
                        bullet.style.left = left+50 +'px';
                        bullet.style.top = top+ 25 +'px';
                    }
                }
                bullet.append(imgs);
                document.getElementById('biggestbox').append(bullet); 

                if(now >= 9) {//延迟2秒填装子弹
                    setTimeout(function(){
                        now = 0;
                        document.querySelector('.wen').textContent = 10;
                    },2000)
                }
            }

            //寒冰镖
            function Lasergun(left,top,n,x) {
                let arms = document.getElementById('arms');
                if(arms.style.display !== 'block') {
                    return;
                }
                let imgs =new Image();
                document.getElementById('bullet').src = './imgs/Cold_ice.png'//切换飞镖图片
                arms.src = './imgs/Cold_ice.png'
                imgs.src ='./imgs/Cold_ice.png';//子弹图片
                
                let bullet =  document.createElement('p');
                bullet.className = '_arms';
                $('#bullet').attr("data-key",'Cold_ice');//寒冰
                //子弹位置
                if(x ==74) {
                    if(n == 65 ) {
                        bullet.style.left = left+'px';
                        bullet.style.top = top+ 25 +'px';
                    }else if( n == 68) {
                        bullet.style.left = left+50 +'px';
                        bullet.style.top = top+ 25 +'px';
                    }
                }
                bullet.append(imgs);
                document.getElementById('biggestbox').append(bullet); 

                if(now >= 4) {//延迟2秒填装子弹
                    setTimeout(function(){
                        now = 0;
                        document.querySelector('.wen').textContent = 5;
                    },2000)
                }
            }

            //武器出现位置图片  创建新武器
            let arr_arms = [
                'Cold_ice','Flame'
            ]
             function new_arms() {
                // if(sum < 10000) {
                //     return;
                // }
                let new_weapons = document.querySelectorAll('.arm')[0];
                if(new_weapons) {
                    // s = 0;
                    return;
                }
                let weapons = document.createElement('p');
                let imge = new Image();
                imge.src = './imgs/Cold_ice.png'
                weapons.append(imge);
                weapons.style.left = 570 + 'px';
                weapons.style.top = 270 + 'px';
                weapons.className= 'arm';
                document.getElementById('biggestbox').append(weapons);
               
            }
            //吃武器
            function qie() {
                let new_weapons = document.querySelectorAll('.arm')[0];
                if(!new_weapons) {
                    return;
                }
                let lead_concent_left = document.getElementById('lead').offsetLeft + 25 ;//中心点
                let  lead_concent_top =  document.getElementById('lead').offsetTop + 25;//中心点
                if(lead_concent_left >= new_weapons.offsetLeft && lead_concent_left <= new_weapons.offsetLeft + 50) {
                    if(lead_concent_top >= new_weapons.offsetTop && lead_concent_top <= new_weapons.offsetTop + 50) {
                        new_weapons.remove();
                        document.getElementById('bullet').src = './imgs/Cold_ice.png'//切换飞镖图片
                        $('#bullet').attr('data-key','Cold_ice');
                        document.querySelector('.wen').textContent = 5;
                    }
                }
             }

             //boss子弹射击
             function boss_fun(lead) {
                let ours_boss_bullets = document.querySelectorAll('.Darts');
                for(let i = 0; i<ours_boss_bullets.length;i++) {
                    if( ours_boss_bullets[i].offsetLeft >= lead.offsetLeft && ours_boss_bullets[i].offsetLeft <= lead.offsetLeft +50) {
                        if( ours_boss_bullets[i].offsetTop >= lead.offsetTop && ours_boss_bullets[i].offsetTop <= lead.offsetTop + 50) {
                            ours_boss_bullets[i].remove();
                            let lead_number = document.getElementsByClassName('lead_number')[0];//血条
                            lead_number.textContent = lead_number.textContent - 1;//碰到血条减1

                            if(lead_number.textContent <= 0){//当血条为0时候
                                lead.remove();
                                document.getElementById('geameoverbox').style.display= 'block'
                                geamname();
                            }
                        }
                    }
                  
                    ours_boss_bullets[i].style.left =  ours_boss_bullets[i].offsetLeft + 20+'px';
                    if(ours_boss_bullets[i].offsetLeft > 1200) {
                        ours_boss_bullets[i].remove();//清楚子弹
                    }
                    
                }
             }
             //子弹打到boss
             function player_boss(currentleft,currenttop,bullets_ky) {
                let first_boss = document.querySelector('.first_boss');
                if(!first_boss){
                    return
                }
                let first_boss_leftt = document.querySelector('.first_boss').offsetLeft;
                let first_boss_top = document.querySelector('.first_boss').offsetTop;
                console.log(first_boss_leftt,first_boss_top)
                if(currentleft >= first_boss_leftt && currentleft <= first_boss_leftt + 300){//小于左边大于右边
                    if(currenttop >= first_boss_top && currenttop <= first_boss_top + 300){
                        
                        let first_boss_blood = document.querySelector('.first_boss').getAttribute('data-key');//获得boss data-key的值也就是血量
                        let bullet_key = document.getElementById('bullet').getAttribute('data-key');//获取子弹类型

                        if(bullet_key == 'Cold_ice') {//冰弹扣5血
                            first_boss_blood = Number(first_boss_blood) - 5;
                        }
                        if(bullet_key == 'ordinary') {//普通扣2血
                            first_boss_blood = Number(first_boss_blood) - 2;
                        }
                        $('.first_boss').attr('data-key',first_boss_blood);
                        if(first_boss_blood <=0) {
                            first_boss.remove();
                            new_arms()
                            document.getElementById('fen').textContent = Number(document.getElementById('fen').textContent) + 100 ;
                        }
                        bullets_ky.remove();//清楚子弹
                    }
                }
            }
            
            //子弹射击
            // bulletfly()
            let n = 0;
            let m = 0;
            let s = 0;
            let our_num = 0
            function bulletfly() {
                let add = setInterval(function() {
                    let lead = document.getElementById('lead')
                    if(!lead) {//删除定时器
                        clearInterval(add);
                    }
                    track();//角色死亡
                    boos_move(n);//怪物创建
                    blood(m);//创建血包
                    // console.log(n)
                    player_blood()//血包加血方法
                    // new_arms(s)//创建新的武器
                    n = n + 20;
                    m = m + 20;
                    s = s + 20;
                    our_num = our_num + 50
                    qie();
                    //boss射击子弹
                    boss_shooter(our_num);

                    boss_fun(lead)
                   


                    let bullets = document.querySelectorAll('._arms');//所有子弹
                    let boss_move = document.querySelectorAll('.boss_move')//所有的怪
                    let currentleft;//子弹左位置
                    let currenttop;//子弹高度与
                    let boss_range_left;//怪物左位置
                    let boss_range_right;//怪物右位置
                    let boss_range_top;//怪物高度
                    let boss_range_width;//怪物hight
                    let left  = lead.offsetLeft;    
                    let top   = lead.offsetTop;
                    //获得子弹的左边位置
                    let bullet_left = left;
                    let bullet_lefttop = top+ 25;
                    //获得子弹的右边位置
                    let bullet_right = left+30 ;
                    let bullet_righttop =  top+ 25;
                    let lead_left = document.getElementById('lead').offsetLeft + 25;
                    //子弹与小怪物
                    for(let x = 0; x < bullets.length;x++){
                        //每个子弹的位置
                        currentleft = bullets[x].offsetLeft;
                        currenttop =  bullets[x].offsetTop;
                        let bullets_ky = bullets[x];
                        player_boss(currentleft,currenttop,bullets_ky);
                        for(let y = 0; y < boss_move.length; y++) {//子弹受击怪
                            boss_range_left = boss_move[y].offsetLeft;
                            boss_range_right =boss_move[y].offsetLeft +50;
                            boss_range_top = boss_move[y].offsetTop;
                            boss_range_width = boss_move[y].offsetTop +50;
                            let boss_data = boss_move[y].getAttribute('data-key');//获得每个怪物data-key的值也就是血量

                            

                            if(currentleft <= boss_range_right && currentleft >= boss_range_left){//小于左边大于右边
                                if(currenttop <=boss_range_width && currenttop >= boss_range_top){
                                    let data_boss = boss_move[y].getAttribute('data-key');//获得每个怪物data-key的值也就是血量
                                    bullet_key = document.getElementById('bullet').getAttribute('data-key');//获取子弹类型

                                    if(bullet_key == 'Cold_ice') {//冰弹扣5血
                                        data_boss = data_boss - 5;
                                    }
                                    if(bullet_key == 'ordinary') {//普通扣2血
                                        data_boss = data_boss - 2;
                                    }
                                    
                                    $(boss_move[y]).attr('data-key',data_boss);
                                    
                                    if(data_boss <=0) {
                                        //爆炸图片切换
                                        document.querySelectorAll('.boss_move img')[y].src = './imgs/blast.png';
                                        document.querySelectorAll('.boss_move img')[y].style.top = -15 +'px';
                                        // boss_move[y].src = './imgs/blast.png';
                                        setTimeout(function(){
                                            boss_move[y].remove();
                                            let fen = document.getElementById('fen');
                                            // if(move > 50) {//move怪物血量 加分机制
                                            //     fen.textContent = Number(fen.textContent) + 2 ;
                                            // }else {
                                                fen.textContent = Number(fen.textContent) + 1 ;
                                            // }
                                        },100)
                                        
                                    
                                    }
                                    bullets[x].remove();//子弹消失
                                    
                                    //寒冰镖击退
                                    if(bullet_key == 'Cold_ice') {
                                        if(boss_range_left < left) {
                                            boss_move[y].style.left = boss_range_left - 50 +'px';
                                        }
                                        if(boss_range_left > left) {
                                            boss_move[y].style.left = boss_range_left + 50 +'px';
                                        }
                                    }
                                
                                }
                            }
                        }

                        //子弹方向移动
                        if(currentleft < lead_left) {
                            if(currentleft < 100) {
                                bullets[x].remove();
                            }else {
                                bullets[x].style.left = currentleft - 20+ 'px'
                            }
                        }
                        if(currentleft > lead_left) {
                            if(currentleft > 1100) {
                                bullets[x].remove()
                            }else {
                                bullets[x].style.left = currentleft + 20+ 'px'
                            }
                        }
                    
                    }
                }, 20);
            }
            //回血机制
            function player_blood() {
                let blood = document.querySelectorAll('.blood');
                let lead_concent_left = document.getElementById('lead').offsetLeft + 25 ;//中心点
                let  lead_concent_top =  document.getElementById('lead').offsetTop + 25;//中心点
                blood.forEach(blood => {
                    if(lead_concent_left >= blood.offsetLeft && lead_concent_left <=  blood.offsetLeft + 20) {
                        if(lead_concent_top >= blood.offsetTop && lead_concent_top <= blood.offsetTop +20){
                            blood.remove()
                            let bloodnumber =  document.querySelector('.lead_number');
                            if(bloodnumber.textContent > 4) {
                                bloodnumber.textContent = 5;
                            }else {
                                bloodnumber.textContent =Number(bloodnumber.textContent)+ 1;
                            }
                            
                        }
                    }
                })
            }
            // boss子弹
            function boss_shooter(hou) {
                if(hou < 1000) {//boss子弹射击速度
                    return
                }
                let boss = document.querySelector('.first_boss');
                if(!boss) {
                    return;
                }
                //15
                let arr = [
                    {
                        left: 240,
                        top:10
                    },
                    {
                        left: 240,
                        top:40
                    },
                    {
                        left: 240,
                        top:70
                    },
                    {
                        left: 240,
                        top: 100
                    },
                    {
                        left: 240,
                        top: 130
                    },
                    {
                        left: 240,
                        top:160
                    },
                    {
                        left: 240,
                        top:190
                    },
                    {
                        left: 240,
                        top: 220
                    },
                    {
                        left: 240,
                        top:250
                    },
                    {
                        left: 240,
                        top: 280
                    },
                    {
                        left: 240,
                        top:310
                    },
                    {
                        left: 240,
                        top: 340
                    },
                    {
                        left: 240,
                        top:370
                    },
                    {
                        left: 240,
                        top: 400
                    },
                    {
                        left: 240,
                        top:430
                    },
                    {
                        left: 240,
                        top:460
                    },
                    {
                        left: 240,
                        top:490
                    }
                ]
                let boss_shooter_random =parseInt(Math.random()*16);
                let boss_shooter = document.createElement('p');
                let imge = new Image();
                imge.src = './imgs/12.png'
                boss_shooter.append(imge);
                boss_shooter.style.left = 240+ 'px';
                boss_shooter.style.top = arr[boss_shooter_random].top+ 25 + 'px';
                boss_shooter.className= 'Darts';
                document.getElementById('biggestbox').append(boss_shooter);
                our_num = 0;
               
            }
        }
    }
}